//
//  MCDayWageGetSystemTypeModel.m
//  TLYL
//
//  Created by MC on 2018/1/9.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCDayWageGetSystemTypeModel.h"
#import "NSDictionary+helper.h"
#import "NSString+Helper.h"

@interface MCDayWageGetSystemTypeModel ()<ApiManagerCallBackProtocol,ApiManagerProvider,ApiManagerProtocol>
{
    
    NSDictionary * _dic;
}
@end

@implementation MCDayWageGetSystemTypeModel
singleton_m(MCDayWageGetSystemTypeModel)
- (instancetype)initWithDic:(NSDictionary *)dic{
    
    if (self = [super init]) {
        _dic = dic;
    }
    return self;
}



- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
};
-(BOOL)isShowHud{
    return NO;
}
- (BOOL)isShowError{
    return NO;
}
- (BOOL)isShowNoNet{
    return NO;
}
- (BOOL)isShowNodata{
    return NO;
}
- (enum ManagerRequestMethod)requestMethod{
    
    return ManagerRequestMethodRequestMethodRestPOST;
}

- (enum APIResponseDataType)responseDataType{
    
    return APIResponseDataTypeJson;
}
- (void)refreashDataAndShow{
    
    ApiBaseManager *baseManager = [[ApiBaseManager alloc] initWithUrlProvider:self];
    baseManager.apiCallBackDelegate = self;
    baseManager.requestCustomizeDelegate = self;
    [baseManager loadData];
    
}

- (NSDictionary<NSString *,NSString *> *)headerForManagerWithManager:(ApiBaseManager *)manager{
    NSString *token = @"";
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"token"]) {
        token = [[NSUserDefaults standardUserDefaults] objectForKey:@"token"];
        
    }
    return @{@"token":token,@"platformCode":@"5"};
}

- (NSString *)urlPathComponentForManagerWithManager:(ApiBaseManager *)manager{
    
    return @"web-api/api/v4/get_system_type";
    
}

- (NSDictionary<NSString *,id> *)parametersForManagerWithManager:(ApiBaseManager *)manager{
    
    NSString *timeString = [NSString getCurrentTimestamp];
    
    NSDictionary *dic =@{@"TypeID":@"1"};
    
    NSString *jsonStr = [dic convertToJsonData];
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",jsonStr,[[NSUserDefaults standardUserDefaults] objectForKey:@"token"],timeString];
    return @{@"params":jsonStr,
             @"sign":[sign MD5],
             @"timestamp":timeString
             };
}

- (void)managerCallAPIDidSuccessWithManager:(ApiBaseManager *)manager{
    
    
    if (self.callBackSuccessBlock) {
        self.callBackSuccessBlock(manager.ResponseRawData);
    }
    
}

- (void)managerCallAPIDidFailedWithManager:(ApiBaseManager *)manager errorCode:(NSString *)errorCode{
    
    if (self.callBackFailedBlock) {
        self.callBackFailedBlock(manager,errorCode);
    }
    NSLog(@"er=----%@",errorCode);
}
-(NSMutableArray *)R_nameDataSource{
    if (!_R_nameDataSource) {
        
        _R_nameDataSource=[[NSMutableArray alloc]init];
        
    }
    return _R_nameDataSource;
}

-(NSMutableArray *)R_dayWageDataSource{
    if (!_R_dayWageDataSource) {
        
        _R_dayWageDataSource=[[NSMutableArray alloc]init];
        
    }
    return _R_dayWageDataSource;
}
-(NSMutableArray *)dayWageDataSource{
    if (!_dayWageDataSource) {
        
        _dayWageDataSource=[[NSMutableArray alloc]init];
        
    }
    return _dayWageDataSource;
}

-(NSMutableArray *)nameDataSource{
    if (!_nameDataSource) {
        _nameDataSource = [[NSMutableArray alloc]init];
    }
    return _nameDataSource;
}
-(void)setDataSource:(NSArray *)arr{

    [self.R_dayWageDataSource removeAllObjects];
    [self.R_nameDataSource removeAllObjects];
    [self.dayWageDataSource removeAllObjects];
    [self.nameDataSource removeAllObjects];
    
    MCBaseGetSystemTypeModel * model0 = [[MCBaseGetSystemTypeModel alloc]init];
    model0.Id = @"-1";
    model0.Name = @"全部";
    [self.R_dayWageDataSource addObject:model0];
    [self.R_nameDataSource addObject:model0.Name];
    
    for (NSDictionary * dic  in arr) {
        MCBaseGetSystemTypeModel * model = [[MCBaseGetSystemTypeModel alloc]init];
        model.Id = [NSString stringWithFormat:@"%@",dic[@"Id"]];
        model.Name = [NSString stringWithFormat:@"%@",dic[@"Name"]];
        [self.dayWageDataSource addObject:model];
        [self.nameDataSource addObject:[NSString stringWithFormat:@"%@",dic[@"Name"]]];
        [self.R_dayWageDataSource addObject:model];
        [self.R_nameDataSource addObject:[NSString stringWithFormat:@"%@",dic[@"Name"]]];
    }
}

@end














